<?php
/* @var $this SiteController */

$this->pageTitle=Yii::app()->name;
?>
<script>
	function getClassList(gid,did,mid)
	{
		$('#class').load('<?php echo Yii::app()->request->baseUrl;?>/notification/getallclasslist?gid='+gid+'&did='+did+'&mid='+mid);
	}
	
	function getMajorList(did)
	{
		$('#major').load('<?php echo Yii::app()->request->baseUrl;?>/notification/getallmajorlist?did='+did,getClassList($('#grade').val(),$('#department').val(),$('#major').val()));
	}
</script>

<div class="container" style="width:650px;height:400px;padding-top:50px">
    <div class="jumbotron">
			<form action="<?php echo Yii::app()->request->baseUrl; ?>/notification/groupsend" method="post" accept-charset="utf-8" role="form">
				<h2>群体通知发送</h2>
				<table class="table">  
					<tr>
						<td>
							<select id="grade" name="grade" class="form-control" onchange="getClassList($('#grade').val(),$('#department').val(),$('#major').val())" required>
							<?php
								$list=Grade::model()->findAll();
								$res='<option value="All">所有</option>';
								for ($i=0;$i<count($list);$i++)
									$res=$res.'<option value="'.($list[$i]->grade_id).'">'.($list[$i]->name).'</option>';
								echo $res;
							?>
							</select>
						</td>
					</tr>
					<tr>
						<td>
							<select id="department" name="department" class="form-control" onchange="getMajorList(this.value)" required>
							<?php
								$list=Department::model()->findAll();
								$res='<option value="All">所有</option>';
								for ($i=0;$i<count($list);$i++)
									$res=$res.'<option value="'.($list[$i]->department_id).'">'.($list[$i]->name).'</option>';
								echo $res;
							?>
							</select>
						</td>
					</tr>
					<tr>
						<td>
							<select id="major" name="major" class="form-control" onchange="getClassList($('#grade').val(),$('#department').val(),this.value)" required>
							<?php
								$list=Major::model()->findAll();
								$res='<option value="All">所有</option>';
								for ($i=0;$i<count($list);$i++)
									$res=$res.'<option value="'.($list[$i]->major_id).'">'.($list[$i]->name).'</option>';
								echo $res;
							?>
							</select>
						</td>
					</tr>
					<tr>
						<td>
							<select id="class" name="class" class="form-control" required>
							<option value="All">所有</option>
							</select>
						</td>
					</tr>
					<tr>
						<td>
							<div class="input-group">
								<input type="text" name="title" class="form-control" placeholder="标题" required />
							</div>
						</td>
					</tr>
					<tr>
						<td>
							<div class="input-group">
								<textarea name="content" style="width:400px" placeholder="通知内容" required></textarea>
							</div>
						</td>
					</tr>
					
					<tr>
						<td><input class="btn btn-success" type="submit" role="button" value="发送"/></td>
						<td><a class="btn btn-success" href="<?php echo Yii::app()->request->baseUrl; ?>/notification/index" role="button">返回</a></td> 
					</tr>  
				</table>
			</form>
	</div>
</div>

